﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Xml;

namespace Jy123.Common.Config
{
    public class BaseConfig
    {
        /// <summary>
        /// 获取配置文件的值
        /// </summary>
        /// <param name="Target">配置节名称</param>
        /// <returns>对应配置节的值</returns>
        public static string GetConfigValue(string Target)
        {
            string path = HttpContext.Current.Server.MapPath("~/config/base/JySite.config");
            return GetConfigValue(Target, path, new bool[1]);
        }
        /// <summary>
        /// 获取配置文件的值
        /// </summary>
        /// <param name="Target">配置节名称</param>
        /// <param name="XmlPath">配置文件所在路径</param>
        /// <param name="cdata"></param>
        /// <returns>对应配置节的值</returns>
        internal static string GetConfigValue(string Target, string XmlPath, params bool[] cdata)
        {
            XmlDocument xdoc = new XmlDocument();
            xdoc.Load(XmlPath);
            XmlNode node = xdoc.DocumentElement.SelectSingleNode(Target);
            if (node != null)
            {
                if ((cdata != null) && cdata[0])
                {
                    return node.InnerText;
                }
                return node.InnerXml;
            }
            return string.Empty;
        }
    }
}
